cmake_minimum_required(VERSION 3.5)

project(cmake_qt_entry LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
# 设置翻译文件
set(TS_FILES cmake_qt_entry_zh_CN.ts)

#设置exe图标资源文件
IF (WIN32) # windows
    set(app_WINRC app_win32.rc)
    set_property(SOURCE app_win32.rc APPEND PROPERTY
        OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/images/cpp.ico
        )
ELSE () # linux
    set(app_WINRC "")
ENDIF ()


add_executable(${PROJECT_NAME} 
main.cpp
CMakeMainWindow.cpp
CMakeMainWindow.h
CMakeMainWindow.ui
main.qrc
${app_WINRC}
${TS_FILES}
)

target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets)

qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
